package com.goodmr.passport.auth;

import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;

/**
 * 验证码数据实体
 *
 * 为了安全，与帐号数据仓库分开储存
 * 建议存储到内存型数据库中（如：redis）
 *
 * @author <a href="mailto:bingdong13@msn.com">bigo</a>
 */
@Entity
@Table(name = "verify_code")
@Data
class VerifyCodeEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 接收者
     */
    @Column(length = 100, nullable = false)
    private String receiver;

    /**
     * 验证码
     */
    @Column(nullable = false, length = 8)
    private String code;

    /**
     * 创建时间
     */
    @Column(name = "created_at", nullable = false, updatable = false)
    private Timestamp createdAt;

    /**
     * 失效时间
     */
    @Column(name = "expired_at", nullable = false)
    private Timestamp expiredAt;
}
